<template>
<div>

  <el-row :span="24" class="header">
    <title-info v-bind:sysUserName="''" v-bind:sysUserAvatar="''"></title-info>
  </el-row>



 <el-form v-show="login_show" :model="ruleForm2" :rules="rules2" ref="ruleForm2" label-position="left" label-width="0px" class="demo-ruleForm login-container">
    <h3 class="title">系统登录</h3>
    <el-form-item prop="account">
      <el-input type="text" v-model="ruleForm2.account" auto-complete="off" placeholder="请输入账号" @keyup.enter.native="handleLogin"></el-input>
    </el-form-item>
    <el-form-item prop="checkPass">
      <el-input type="password" v-model="ruleForm2.checkPass" auto-complete="off" placeholder="请输入密码" @keyup.enter.native="handleLogin"></el-input>
    </el-form-item>
    <!-- <el-form-item>
      <el-col :span="12">
        <el-checkbox v-model="checked" checked class="remember_psw">记住密码</el-checkbox>
      </el-col>
      <el-col :span="12">
        <el-row  type="flex" justify="end">
          <u class="forget_psw" @click="forgetPsw" style="cursor:pointer">忘记密码?</u>
        </el-row>
      </el-col>
    </el-form-item> -->
    <el-form-item style="width:100%;">
      <el-button round type="primary" style="width:100%;" @click="handleLogin" :loading="logining">登录</el-button>
      <!--<el-button @click.native.prevent="handleReset2">重置</el-button>-->
    </el-form-item>
  </el-form>

  <el-form v-show="find_psw_show" :model="find_psw_Form" label-position="left" label-width="0px" class="find_psw">
    <el-form-item prop="account">
      <el-input type="text" v-model="find_psw_Form.account" auto-complete="off" placeholder="请输入账号" class="input_account"></el-input>
    </el-form-item>
    <el-form-item style="width:100%;">
      <el-button round type="primary" style="width:100%;" @click.native="lastStepClick" >上一步</el-button>
    </el-form-item>
    <el-form-item style="width:100%;">
      <el-button round type="primary" style="width:100%;" @click.native="nextStepClick" >下一步</el-button>
      <!--<el-button @click.native.prevent="handleReset2">重置</el-button>-->
    </el-form-item>
  </el-form>

  <el-form v-show="phone_verification_show" :model="phone_verification_Form" label-position="left" label-width="0px" class="phone_verification">
    <el-form-item prop="code">
      <el-input type="text" v-model="phone_verification_Form.code" auto-complete="off" placeholder="请输入收到的验证码" class="input_code"></el-input>
    </el-form-item>
    <el-form-item prop="psw">
      <el-input type="password" v-model="phone_verification_Form.psw" auto-complete="off" placeholder="请输入新密码" class="input_psw"></el-input>
    </el-form-item>
    <el-form-item style="width:100%;">
      <el-button round type="primary" style="width:100%;" @click.native="lastStepClick2" >上一步</el-button>
    </el-form-item>
    <el-form-item style="width:100%;">
      <el-button round type="primary" style="width:100%;" @click.native="code_show" >确定</el-button>
      <!--<el-button @click.native.prevent="handleReset2">重置</el-button>-->
    </el-form-item>
  </el-form>

  <el-form v-show="contact_admin_show" label-position="left" label-width="0px" class="contact_admin">
    <el-form-item prop="admin">
      <el-row  type="flex" justify="center">
      <p>请联系您的管理员修改密码</p>
      </el-row>
    </el-form-item>
    <el-form-item style="width:100%;">
      <el-button round type="primary" style="width:100%;" @click.native="back_login" >返回登录</el-button>
      <!--<el-button @click.native.prevent="handleReset2">重置</el-button>-->
    </el-form-item>
  </el-form>

</div>
</template>

<script>
import {requestLogin, requestSendCode, getRoleGroup} from '../api/api'
import { TitleInfo } from '@/views/main/components'
import { initUserInfo } from '@/utils/role.js'
import { printLog } from '@/utils/console.js'

export default {
  name: 'login',
  components: {
	  TitleInfo
  },
  data() {
      return {
        img_logo:"",
        login_show:true,
        find_psw_show:false,
        phone_verification_show:false,
        contact_admin_show: false,
        logining: false,
        platform: '',
        ruleForm2: {
          // account: 'xiaoyitest@xiaoyi.com',
          // checkPass: 'admin888'
          account: '',
          checkPass: ''
        },
        find_psw_Form: {
          account: ''
        },
        phone_verification_Form: {
          code: '',
          psw: ''
        },
        rules2: {
          account: [
            { required: true, message: '请输入账号', trigger: 'blur' },
            //{ validator: validaePass }
          ],
          checkPass: [
            { required: true, message: '请输入密码', trigger: 'blur' },
            //{ validator: validaePass2 }
          ]
        },
        checked: true
      };
    },
    mounted() {
      printLog('mounted');
      // this.handleLogin(null)
    },
    methods: {
      forgetPsw: function() {
        
      },
      handleReset2() {
        this.$refs.ruleForm2.resetFields();
      },
      handleLogin() {
        printLog('handleLogin');
          sessionStorage.setItem("test" + '_sessionToken', "data.data.cid");
        this.$router.push({ path:'/Home'});
      },
      lastStepClick: function() {
        
      },
      lastStepClick2: function() {
      },
      nextStepClick: function() {
        var regPhone = 11 && /^((13|14|15|17|18)[0-9]{1}\d{8})$/;
        var regEmail = /^[A-Za-zd0-9]+([-_.][A-Za-zd0-9]+)*@([A-Za-zd]+[-.])+[A-Za-zd]{2,5}$/;
        if (regPhone.test(this.find_psw_Form.account)) {
          // this.find_psw_show = false;
          // this.phone_verification_show = true;
          this.request_send_code();
        } else if (regEmail.test(this.find_psw_Form.account)) {
          this.find_psw_show = false;
          this.contact_admin_show = true;
        } else {
          this.$message({
            showClose: true,
						message: '请输入正确的账号',
						type: 'warning'
					});
        }
      },
      code_show: function() {
      },
      back_login :function() {
      },
      request_send_code: function() {
      },
      reset_psw:function() {
      }
    }
}
</script>

<style lang="scss" scoped>
  .header {
    height: 60px;
    background: #304156;
    box-shadow: 0px 2px 2px #304156;
    .logo {
      width:40px;
      height:40px;
      margin: 10px 0px 10px 20px;
    }
    .txt-section {
      font-size: 20px;
      margin-left: 15px;
    }
  }
  
  .login-container {
    /*box-shadow: 0 0px 8px 0 rgba(0, 0, 0, 0.06), 0 1px 0px 0 rgba(0, 0, 0, 0.02);*/
    -webkit-border-radius: 5px;
    border-radius: 5px;
    -moz-border-radius: 5px;
    background-clip: padding-box;
    margin: 180px auto;
    width: 350px;
    padding: 35px 35px 15px 35px;
    background: #fff;
    border: 1px solid #eaeaea;
    box-shadow: 0 0 25px #cac6c6;
    .title {
      margin: 0px auto 40px auto;
      text-align: center;
      color: #505458;
    }
    .remember_psw {
      margin: 0px 0px 0px 0px;
    }
    .forget_psw {
      color: #505458;
    }
  }
  .find_psw {
    -webkit-border-radius: 5px;
    border-radius: 5px;
    -moz-border-radius: 5px;
    background-clip: padding-box;
    margin: 180px auto;
    width: 350px;
    padding: 35px 35px 15px 35px;
    background: #fff;
    border: 1px solid #eaeaea;
    box-shadow: 0 0 25px #cac6c6;
    .input_account {
      margin: 20px 0px 20px 0px;
    }
  }
  .phone_verification, .contact_admin {
    -webkit-border-radius: 5px;
    border-radius: 5px;
    -moz-border-radius: 5px;
    background-clip: padding-box;
    margin: 180px auto;
    width: 350px;
    padding: 35px 35px 15px 35px;
    background: #fff;
    border: 1px solid #eaeaea;
    box-shadow: 0 0 25px #cac6c6;
  }
</style>